package com.vlefen.springcloud.grpc.config;

import com.vlefen.springcloud.grpc.util.HostUtils;
import io.netty.handler.ssl.ClientAuth;
import io.netty.util.NetUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.UnknownHostException;

@Data
@ConfigurationProperties("grpc")
public class GRpcProperties {

    private final Server server = new Server();


    public static class Client {
        private boolean enabledTLS = false;
        private boolean failFast = false;
    }

    @Data
    public static class Server {
        private String instanceId;
        private int port = 0;
        private String address = "127.0.0.1";
        private String healthCheckInterval = "10s";
        private String hostName = HostUtils.HOST_NAME;
        private final ServerSsl ssl = new ServerSsl();
        private boolean failFast = false;
    }

    @Data
    public static class ServerSsl {
        private boolean enabled = false;
        private ClientAuth clientAuth;
        private String[] ciphers;
        private String[] enabledProtocols;
        private String keyAlias;
        private String keyPassword;
        private String keyCertChainFile;
        private String keyFile;
    }

}
